#! /usr/bin/perl
use strict;
use warnings;
use Person::Student;
use Person::TAStudent;
use Person::Persons;

my $size;
my $count;
sub createList{
	$size = shift;
}
sub printSome{
	my $hm = shift;
	if($hm > $count){
		print "There are only $count elements in the list.\nTry again.\n";
		return;
	}
	#my @list = $_[1];
	foreach(my $i = 0; $i<$hm; $i++){
		print 'ELEMENT ' . ($i+1) .  "\n";
		$_[$i]->toString;
	}
}

my $p2 = Person::Persons->new("Leo", "Messi", "240787-8888", "gud");
my $p1 = Person::Student->new("Juan", "Perez", "220212-2222", "male");
if(defined $p1){
$p1->first_name("Pedro");
$p1->gender;
$p1->toString;
$p1->grades("Math", 0, "Spanish", 6);
$p1->grades("Programming", 10);
$p1->avg;
}
my $ta1 = Person::TAStudent->new("Julian", "Laver", "230581-4321", "male", ["Math", "Physics"]);
$ta1->toString;
if(defined($p1->equals($ta1))){
	print "It is the same person.\n";
}else{
	print "It is NOT the same person.\n";
}
print "Your database size: ";
chomp(my $input = <STDIN>);
&createList($input);
my @studs; 
if ($input == $size){
	print "Database of size $input created.\n";
}
push (@studs, $p1);
push (@studs, $ta1);
push (@studs, $p2);
$count = 2;
print "How many elements do you want to print?";
chomp($input = <STDIN>);
&printSome($input, @studs);

